//
//  FKChooseBankCardCell.m
//  HappyTest
//
//  Created by Macbook Pro on 2019/2/12.
//  Copyright © 2019 Macbook Pro. All rights reserved.
//

#import "FKChooseBankCardCell.h"

@interface FKChooseBankCardCell ()

@property (nonatomic, weak) UILabel *titleLabel;
@property (nonatomic, weak) UILabel *cardNumLabel;
@property (nonatomic, weak) UIImageView *rightIcon;

@end

@implementation FKChooseBankCardCell

- (void)setupSubviews
{
    [super setupSubviews];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    UILabel *titleLabel = [UILabel fk_labelWithFont:fk_adjustFont(14) textColor:fkColor333333];
    [self.contentView addSubview:titleLabel];
    self.titleLabel = titleLabel;
    
    UILabel *cardNumLabel = [UILabel fk_labelWithFont:fk_adjustFont(12) textColor:fkColor666666];
    [self.contentView addSubview:cardNumLabel];
    self.cardNumLabel = cardNumLabel;
    
    UIImageView *rightIcon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bank_icon_select_n"]];
    [self.contentView addSubview:rightIcon];
    self.rightIcon = rightIcon;
    rightIcon.highlightedImage = [UIImage imageNamed:@"bank_icon_select_s"];
    
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(12);
        make.top.offset(8);
    }];
    [cardNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(titleLabel);
        make.bottom.offset(-8);
    }];
    [rightIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-12);
        make.centerY.offset(0);
    }];
}

- (void)setData:(id)data
{
    [super setData:data];
    
    self.titleLabel.text = data[@"name"];
    self.cardNumLabel.text = data[@"bank_number"];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    
//    self.rightIcon.hidden = !selected;
    self.rightIcon.highlighted = selected;
}

@end
